﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.EntityValidation
{
    public class InAttribute : ValidationAttribute
    {

        public InAttribute()

        {
            ErrorMessage = "{0}不在区间之内";

        }
        public string Range { get; set; }
        public char RangeSplit { get; set; }
        public override bool Verify(object o)
        {

            string input = null;
            if (o == null)
            {

                return false;
            }

            input = o.ToString();
            var arr = Range.Split(',');

            if (!string.IsNullOrWhiteSpace(Range) && !arr.Contains(input))
            {
                return false;
            }

            return true;
        }
    }
}